package com.liar.modular.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liar.modular.system.dao.SysMenuMapper;
import com.liar.modular.system.entity.SysMenu;
import com.liar.modular.system.service.ISysMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lk123
 * @since 2020-07-03
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {

    @Override
    public List<SysMenu> menuList() {
        List<SysMenu> menus = menus("0");

        return menus;
    }
    private List<SysMenu> menus(String parent){
        List<SysMenu> list = super.list(new QueryWrapper<SysMenu>().eq("parent", parent).eq("status","1").eq("is_menu","1"));
        for(SysMenu sysMenu:list){
            if(!sysMenu.isEnd()){

                sysMenu.setChildrens(menus(sysMenu.getId()));
            }
        }
        return list;
    }
}
